<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\User;

class MyController extends Controller
{
    public function index(Request $request)
    {
        $userKey = $request->user_key;
        if ($userKey)
        {
            $user = User::with(['roles'])->where('key', $userKey)->firstOrFail();
        }
        else
        {
            $user = \Auth::user();
        }
        return normalize(0, "OK", $user);
    }
}
